home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / FPGAWKII.ZIP / DOWNCNTR.PDS < prev    next >
Text File  |  1994-10-05  |  2KB  |  47 lines

  1. ;---------------------------------------------------------
  2. ; A 3-bit down counter built from DFF flip-flops
  3. ;---------------------------------------------------------
  4. TITLE   3-bit down counter
  5.  
  6. CHIP    dncntr  NFX780_84
  7.  
  8. PIN  47      clock      ;* clock signal for driving counter
  9. PIN  [48:51] unused[0:3]
  10. PIN  [77:78] unused[4:5]
  11. PIN          q[0:2]     ;* 3-bit counter output
  12. PIN  [34:37] s[0:3]     ;* LED segment drivers
  13. PIN  [39:41] s[4:6]     ;* LED segment drivers
  14. MODULE leddigit( d[0:2]=q[0:2], d3=GND, s[0:6]=s[0:6] )
  15.  
  16. EQUATIONS
  17.         ; The following statements make the DFF act like a
  18.         ; toggle FF because we load it with the inverse of
  19.         ; what it currently stores.  That makes the output
  20.         ; of this TFF toggle at 1/2 the clock frequency.
  21.         q0 := /q0
  22.         q0.ACLK = clock
  23.  
  24.         ; This is another toggle FF, but this one is
  25.         ; clocked with the output of the first TFF.  That
  26.         ; makes the output of this TFF toggle at 1/4 of
  27.         ; the clock frequency.
  28.         q1 := /q1
  29.         q1.ACLK = q0
  30.  
  31.         ; A final TFF whose output toggles at 1/8 the
  32.         ; clock frequency.
  33.         q2 := /q2
  34.         q2.ACLK = q1
  35.  
  36. SIMULATION
  37.         VECTOR out := [q2,q1,q0]
  38.         TRACE_ON clock out
  39.         SETF /clock        ; set the clock low
  40.         PRLDF /q0 /q1 /q2  ; clear the counter bits to 0
  41.  
  42.         ; clock it for awhile to see what it does
  43.         FOR i:=0 to 20 DO
  44.                 BEGIN
  45.                 CLOCKF clock
  46.                 END
  47.